<?php
header("content-type:text/html;charset=utf-8");
include "../admin/config/mysql.php";
 $username=$_POST['username'];
 $phone=$_POST['phone'];
 $email=$_POST['email'];
 $password=$_POST['password'];
 $sex=$_POST['sex'];
 $regtime=time();

// 	$pdo -> query("delete from user where id=5"); 

// exit;
$pdo->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
$rs = $pdo -> query("select * from user where username='$username'"); 
$rs->setFetchMode(PDO::FETCH_ASSOC);
// echo $rs->rowCount(); 获取受影响的行数;
if($rs->rowCount()){

	echo "用户名已存在";
	exit;
}
else{

	 $rs=$pdo->query("insert into user(username,phone,email,password,sex,regtime) value ('$username','$phone','$email','$password','$sex','$regtime')");
    
   if($rs){
   	echo "注册成功.<br>";
   	
   	header("refresh:2;url=../log.php");
   	print('正在加载，请稍等...<br>两秒后自动跳转到登入界面~~~');

   }

	
}





?>